package hxy.scan.server.controller;

import hxy.scan.server.dao.mapper.WorkerMapper;
import hxy.scan.server.dao.model.BookModel;
import hxy.scan.server.dao.model.CustomerModel;
import hxy.scan.server.dao.model.FruitModel;
import hxy.scan.server.dao.model.WorkerModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class WorkerController {


    @Resource
    WorkerMapper workerMapper;


    @GetMapping("/worker-create")
    public int create(WorkerModel bookEntity) {

        String name = bookEntity.getName();

        if (name == null) {
            return 0;
        }

        return workerMapper.insert(bookEntity);
    }

    @GetMapping("/worker-list")
    public List<WorkerModel> list() {

        return workerMapper.selectList(null);
    }

    @GetMapping("/worker-update")
    public int update(WorkerModel bookEntity) {
        // 判断ID
        return workerMapper.updateById(bookEntity);
    }

    @GetMapping("/worker-delete")
    public int delete(int id) {
        return workerMapper.deleteById(id);
    }

}

